<script type="text/javascript">


    // 提交修改密码的动作
    function js_update_pass() {
        // 模拟Form提交
        $.ajax({
            type: "POST",
            url: "/user/reset-password",
            data: "email=" + $("#user_email").val(),

            success: function (msg) {
                alert('已经成功重置了密码！请检查电子邮箱！');
                location.href = '/user/info';
            },
            error: function () {
                alert('密码重置失败，请确认Email是否有效，并且两次重置时间大于1分钟！');
            }
        })
    }


    $(document).ready(function () {
        // jquery.validate.js 验证
        $("#form_reset").validate(
                {
                    rules: {
                        user_email: {
                            required: true,
                            email: true
                        }

                    },
                    messages: {
                        user_email: {
                            required: "<span class='red'>请输入正确电子邮箱</span>",
                            email: "<span class='red'>请输入正确的电子邮箱</span>"
                        }
                    }
                }
        );


        $('#sub_reset').click(function () {
            if ($("#form_reset").valid()) {
                // do some stuff
                js_update_pass();
            }
            else {
                // just show validation errors, dont post
            }
        });

    });
</script>

<div class="main">
    <div class="title">
        <span>密码重置</span>
    </div>
    <div class="content">


        <div class="alert alert-warning">请输入邮箱地址重置用户密码，重置后链接在10分钟后失效，请尽快检查邮箱。</div>
        <Br>

        <form class="pure-form pure-form-aligned" role="form" id="form_reset">


            <div class="pure-control-group">
                <label class="col-sm-2 control-label" for="user_email">电子邮箱：</label>


                <input class="form-control" id="user_email" type="text" name="user_email">

            </div>


            <div class="pure-control-group">
                <label class="col-sm-2 control-label"></label>


                <button type="submit" class="pure-button pure-button-primary" id="sub_reset">提交密码重置</button>


            </div>
        </form>
    </div>


</div>




